package com.usian.controller;

import com.usian.pojo.TbUser;
import com.usian.service.SSOService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 用户注册与登录
 */
@RestController
@RequestMapping("/service/sso")
public class SSOServiceController {
    @Resource
    SSOService ssoService;
    //校验用户名或者手机号重复
    @RequestMapping("/checkUserInfo/{checkValue}/{checkFlag}")
    Boolean checkUserInfo(@PathVariable String checkValue, @PathVariable Integer checkFlag){
        return ssoService.checkUserInfo(checkValue,checkFlag);
    }
    //用户注册
    @RequestMapping("/userRegister")
    Integer userRegister(@RequestBody TbUser user){
        return ssoService.userRegister(user);
    }
    //用户登录
    @RequestMapping("/userLogin")
    Map userLogin(@RequestParam String username, @RequestParam String password){
        return ssoService.userLogin(username,password);
    }
    //查询用户登录是否过期
    @PostMapping("/getUserByToken/{token}")
    TbUser getUserByToken(@PathVariable String token){
        return ssoService.getUserByToken(token);
    }
    //用户退出登录
    @PostMapping("/logOut")
    Boolean logOut(@RequestParam String token){
        return ssoService.logOut(token);
    }
}
